<template>
  <el-form label-position="top" class="bold-label form-border">
    <el-form-item label="发送邀请的社区">
      <InvitesList :invites="invites" :loading="loading" />
    </el-form-item>
  </el-form>
</template>

<script>
import InvitesList from './InvitesList';
import { formatInvites } from './format';

export default {
  name: 'SpaceSettingsCommunitiesInvites', // 空间设置-关联社区-受到的邀请
  components: { InvitesList },
  data() {
    return {
      invites: [], // 邀请列表
      loading: false, // 正加载列表
    };
  },
  methods: {
    // 加载列表
    loadInvites() {
      this.loading = true;
      this.$api.spaces.getInvites({
        spaceId: this.$route.params.spaceId,
      }).then(res => this.handleRes(res))
        .catch(() => {})
        .then(() => { this.loading = false; });
    },
    // 处理加载列表返回的信息
    handleRes(res) {
      this.invites = formatInvites(res.data);
    },
  },
};
</script>

<style></style>
